<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>QxOrm: C:/Dvlp/_Perso/QxOrm/include/QxCommon/QxCache.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="logo_qxorm.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">QxOrm
   &#160;<span id="projectnumber">1.4.3</span>
   </div>
   <div id="projectbrief">C++ Object Relational Mapping library</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_qx_cache_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">QxCache.h</div>  </div>
</div>
<div class="contents">
<a href="_qx_cache_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/****************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment">**</span>
<a name="l00003"></a>00003 <span class="comment">** http://www.qxorm.com/</span>
<a name="l00004"></a>00004 <span class="comment">** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)</span>
<a name="l00005"></a>00005 <span class="comment">**</span>
<a name="l00006"></a>00006 <span class="comment">** This file is part of the QxOrm library</span>
<a name="l00007"></a>00007 <span class="comment">**</span>
<a name="l00008"></a>00008 <span class="comment">** This software is provided &#39;as-is&#39;, without any express or implied</span>
<a name="l00009"></a>00009 <span class="comment">** warranty. In no event will the authors be held liable for any</span>
<a name="l00010"></a>00010 <span class="comment">** damages arising from the use of this software</span>
<a name="l00011"></a>00011 <span class="comment">**</span>
<a name="l00012"></a>00012 <span class="comment">** Commercial Usage</span>
<a name="l00013"></a>00013 <span class="comment">** Licensees holding valid commercial QxOrm licenses may use this file in</span>
<a name="l00014"></a>00014 <span class="comment">** accordance with the commercial license agreement provided with the</span>
<a name="l00015"></a>00015 <span class="comment">** Software or, alternatively, in accordance with the terms contained in</span>
<a name="l00016"></a>00016 <span class="comment">** a written agreement between you and Lionel Marty</span>
<a name="l00017"></a>00017 <span class="comment">**</span>
<a name="l00018"></a>00018 <span class="comment">** GNU General Public License Usage</span>
<a name="l00019"></a>00019 <span class="comment">** Alternatively, this file may be used under the terms of the GNU</span>
<a name="l00020"></a>00020 <span class="comment">** General Public License version 3.0 as published by the Free Software</span>
<a name="l00021"></a>00021 <span class="comment">** Foundation and appearing in the file &#39;license.gpl3.txt&#39; included in the</span>
<a name="l00022"></a>00022 <span class="comment">** packaging of this file. Please review the following information to</span>
<a name="l00023"></a>00023 <span class="comment">** ensure the GNU General Public License version 3.0 requirements will be</span>
<a name="l00024"></a>00024 <span class="comment">** met : http://www.gnu.org/copyleft/gpl.html</span>
<a name="l00025"></a>00025 <span class="comment">**</span>
<a name="l00026"></a>00026 <span class="comment">** If you are unsure which license is appropriate for your use, or</span>
<a name="l00027"></a>00027 <span class="comment">** if you have questions regarding the use of this file, please contact :</span>
<a name="l00028"></a>00028 <span class="comment">** contact@qxorm.com</span>
<a name="l00029"></a>00029 <span class="comment">**</span>
<a name="l00030"></a>00030 <span class="comment">****************************************************************************/</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef _QX_CACHE_H_</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define _QX_CACHE_H_</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#pragma once</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00046"></a>00046 <span class="preprocessor">#include &lt;boost/any.hpp&gt;</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include &lt;boost/tuple/tuple.hpp&gt;</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include &lt;boost/tuple/tuple_comparison.hpp&gt;</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include &lt;boost/tuple/tuple_io.hpp&gt;</span>
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="preprocessor">#include &lt;<a class="code" href="_qx_bool_8h.html" title="qx_bool : QxOrm library boolean type with code and description message when an error occured...">QxCommon/QxBool.h</a>&gt;</span>
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 <span class="preprocessor">#include &lt;<a class="code" href="_qx_collection_8h.html" title="QxOrm container (keep insertion order + quick access by index + quick access by key)">QxCollection/QxCollection.h</a>&gt;</span>
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 <span class="preprocessor">#include &lt;<a class="code" href="_qx_singleton_8h.html" title="Concrete class to define a thread-safe singleton of QxOrm library.">QxSingleton/QxSingleton.h</a>&gt;</span>
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="keyword">namespace </span>qx {
<a name="l00058"></a><a class="code" href="namespaceqx_1_1cache.html">00058</a> <span class="keyword">namespace </span>cache {
<a name="l00059"></a><a class="code" href="namespaceqx_1_1cache_1_1detail.html">00059</a> <span class="keyword">namespace </span>detail {
<a name="l00060"></a>00060 
<a name="l00061"></a><a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html">00061</a> <span class="keyword">class </span><a class="code" href="_qx_macro_8h.html#aa569abe24f343fdc4ad5e12e156ba8a2">QX_DLL_EXPORT</a> <a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html">QxCache</a> : <span class="keyword">public</span> qx::<a class="code" href="classqx_1_1_qx_singleton.html" title="qx::QxSingleton&lt;T&gt; : concrete class to define a thread-safe singleton of type T">QxSingleton</a>&lt;QxCache&gt;
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063 
<a name="l00064"></a><a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#a0bc09478f0e5e6a0a6f37cb42e771168">00064</a>    <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classqx_1_1_qx_singleton.html" title="qx::QxSingleton&lt;T&gt; : concrete class to define a thread-safe singleton of type T">qx::QxSingleton</a>&lt;<a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html">QxCache</a>&gt;;
<a name="l00065"></a>00065 
<a name="l00066"></a>00066 <span class="keyword">protected</span>:
<a name="l00067"></a>00067 
<a name="l00068"></a><a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#a330f7fa40af37367b240ed57b95ff548">00068</a>    <span class="keyword">typedef</span> boost::tuple&lt;long, QDateTime, boost::any&gt; <a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#a330f7fa40af37367b240ed57b95ff548">type_qx_cache</a>;
<a name="l00069"></a><a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#acb085c947674a1751bb0da5ddfc6acf9">00069</a>    <span class="keyword">typedef</span> <a class="code" href="classqx_1_1_qx_collection.html">qx::QxCollection&lt;QString, type_qx_cache&gt;</a> <a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#acb085c947674a1751bb0da5ddfc6acf9">type_qx_lst_cache</a>;
<a name="l00070"></a>00070 
<a name="l00071"></a><a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#a7eb2f5a29457bfa50568c820284860c7">00071</a>    <a class="code" href="classqx_1_1_qx_collection.html">type_qx_lst_cache</a> <a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#a7eb2f5a29457bfa50568c820284860c7" title="List of objects in cache under boost::any format.">m_cache</a>;    
<a name="l00072"></a><a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#ab5117cd3afcb1221c77110c96fc40533">00072</a>    QMutex <a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#ab5117cd3afcb1221c77110c96fc40533" title="Mutex =&gt; &#39;QxCache&#39; is thread-safe.">m_oMutexCache</a>;         
<a name="l00073"></a><a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#a23802d320502f4b1ecdfd11ab580758a">00073</a>    <span class="keywordtype">long</span> <a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#a23802d320502f4b1ecdfd11ab580758a" title="Max cost before deleting object in cache.">m_lMaxCost</a>;              
<a name="l00074"></a><a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#a4c21950a486b7a4b0528ddbdefda8506">00074</a>    <span class="keywordtype">long</span> <a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html#a4c21950a486b7a4b0528ddbdefda8506" title="Current cost in cache.">m_lCurrCost</a>;             
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 <span class="keyword">public</span>:
<a name="l00077"></a>00077 
<a name="l00078"></a>00078    <a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html">QxCache</a>();
<a name="l00079"></a>00079    <span class="keyword">virtual</span> ~<a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html">QxCache</a>();
<a name="l00080"></a>00080 
<a name="l00081"></a>00081    <span class="keywordtype">long</span> getCurrCost() <span class="keyword">const</span>;
<a name="l00082"></a>00082    <span class="keywordtype">long</span> getMaxCost() <span class="keyword">const</span>;
<a name="l00083"></a>00083    <span class="keywordtype">void</span> setMaxCost(<span class="keywordtype">long</span> l);
<a name="l00084"></a>00084 
<a name="l00085"></a>00085    <span class="keywordtype">long</span> <a class="code" href="group___qx_cache.html#gace04518e9bf2dd2fca8449037ceffa19" title="Return the number of objects in the cache.">count</a>() <span class="keyword">const</span>;
<a name="l00086"></a>00086    <span class="keywordtype">long</span> size() <span class="keyword">const</span>;
<a name="l00087"></a>00087    <span class="keywordtype">bool</span> isEmpty() <span class="keyword">const</span>;
<a name="l00088"></a>00088    <span class="keywordtype">bool</span> <a class="code" href="group___qx_cache.html#ga1b3b7fe7db7920493f40d0adb9c4957e" title="Return true if the cache contains an object associated with key sKey; otherwise return false...">exist</a>(<span class="keyword">const</span> QString &amp; sKey) <span class="keyword">const</span>;
<a name="l00089"></a>00089    <span class="keywordtype">bool</span> contains(<span class="keyword">const</span> QString &amp; sKey) <span class="keyword">const</span>;
<a name="l00090"></a>00090    boost::any at(<span class="keyword">const</span> QString &amp; sKey);
<a name="l00091"></a>00091    <span class="keywordtype">long</span> insertionCost(<span class="keyword">const</span> QString &amp; sKey);
<a name="l00092"></a>00092    QDateTime insertionDateTime(<span class="keyword">const</span> QString &amp; sKey);
<a name="l00093"></a>00093    <span class="keywordtype">void</span> <a class="code" href="group___qx_cache.html#ga9334ed3464961f8d21fe022ef3a91203" title="Delete all the objects in the cache.">clear</a>();
<a name="l00094"></a>00094 
<a name="l00095"></a>00095    <span class="keywordtype">bool</span> <a class="code" href="group___qx_dao.html#gab4400decee849f008633c52a47508995" title="Insert an element or a list of elements into database.">insert</a>(<span class="keyword">const</span> QString &amp; sKey, <span class="keyword">const</span> boost::any &amp; anyObj, <span class="keywordtype">long</span> lCost = 1, <span class="keyword">const</span> QDateTime &amp; dt = QDateTime());
<a name="l00096"></a>00096    <span class="keywordtype">bool</span> <span class="keyword">remove</span>(<span class="keyword">const</span> QString &amp; sKey);
<a name="l00097"></a>00097 
<a name="l00098"></a>00098 <span class="keyword">private</span>:
<a name="l00099"></a>00099 
<a name="l00100"></a>00100    <span class="keywordtype">void</span> updateCost();
<a name="l00101"></a>00101 
<a name="l00102"></a>00102 };
<a name="l00103"></a>00103 
<a name="l00104"></a>00104 } <span class="comment">// namespace detail</span>
<a name="l00105"></a>00105 } <span class="comment">// namespace cache</span>
<a name="l00106"></a>00106 } <span class="comment">// namespace qx</span>
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 <a class="code" href="_qx_macro_8h.html#ad82efc1fae0529dca4a20067c88a9524">QX_DLL_EXPORT_QX_SINGLETON_HPP</a>(<a class="code" href="classqx_1_1cache_1_1detail_1_1_qx_cache.html">qx::cache::detail::QxCache</a>)
<a name="l00109"></a>00109 
<a name="l00110"></a>00110 namespace qx {
<a name="l00111"></a>00111 <span class="keyword">namespace </span>cache {
<a name="l00112"></a>00112 
<a name="l00117"></a><a class="code" href="group___qx_cache.html#gab21b5d2544f38e06e44a2b7bc52e8262">00117</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___qx_cache.html#gab21b5d2544f38e06e44a2b7bc52e8262" title="Set the maximum allowed total cost of the cache to l. If the current total cost is greater than l...">max_cost</a>(<span class="keywordtype">long</span> l)
<a name="l00118"></a>00118 { <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;setMaxCost(l); }
<a name="l00119"></a>00119 
<a name="l00124"></a><a class="code" href="group___qx_cache.html#ga394ff7635d7c7a4d5f835c864dd3e4db">00124</a> <span class="keyword">inline</span> <span class="keywordtype">long</span> <a class="code" href="group___qx_cache.html#gab21b5d2544f38e06e44a2b7bc52e8262" title="Set the maximum allowed total cost of the cache to l. If the current total cost is greater than l...">max_cost</a>()
<a name="l00125"></a>00125 { <span class="keywordflow">return</span> <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;getMaxCost(); }
<a name="l00126"></a>00126 
<a name="l00131"></a><a class="code" href="group___qx_cache.html#gac78c126e6f75bc48811ea7fc74122ae3">00131</a> <span class="keyword">inline</span> <span class="keywordtype">long</span> <a class="code" href="group___qx_cache.html#gac78c126e6f75bc48811ea7fc74122ae3" title="Return the current cost used by the cache.">current_cost</a>()
<a name="l00132"></a>00132 { <span class="keywordflow">return</span> <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;getCurrCost(); }
<a name="l00133"></a>00133 
<a name="l00138"></a><a class="code" href="group___qx_cache.html#gace04518e9bf2dd2fca8449037ceffa19">00138</a> <span class="keyword">inline</span> <span class="keywordtype">long</span> <a class="code" href="group___qx_cache.html#gace04518e9bf2dd2fca8449037ceffa19" title="Return the number of objects in the cache.">count</a>()
<a name="l00139"></a>00139 { <span class="keywordflow">return</span> <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;count(); }
<a name="l00140"></a>00140 
<a name="l00145"></a><a class="code" href="group___qx_cache.html#ga0c33b55759a4e97d625afa3d42631e07">00145</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group___qx_cache.html#ga0c33b55759a4e97d625afa3d42631e07" title="Return true if the cache contains no object; otherwise return false.">is_empty</a>()
<a name="l00146"></a>00146 { <span class="keywordflow">return</span> <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;isEmpty(); }
<a name="l00147"></a>00147 
<a name="l00152"></a><a class="code" href="group___qx_cache.html#ga9334ed3464961f8d21fe022ef3a91203">00152</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___qx_cache.html#ga9334ed3464961f8d21fe022ef3a91203" title="Delete all the objects in the cache.">clear</a>()
<a name="l00153"></a>00153 { <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;clear(); }
<a name="l00154"></a>00154 
<a name="l00159"></a><a class="code" href="group___qx_cache.html#ga1b3b7fe7db7920493f40d0adb9c4957e">00159</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group___qx_cache.html#ga1b3b7fe7db7920493f40d0adb9c4957e" title="Return true if the cache contains an object associated with key sKey; otherwise return false...">exist</a>(<span class="keyword">const</span> QString &amp; sKey)
<a name="l00160"></a>00160 { <span class="keywordflow">return</span> <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;exist(sKey); }
<a name="l00161"></a>00161 
<a name="l00166"></a><a class="code" href="group___qx_cache.html#gacd19c6b26c18bd3f96a58b639ebaf7db">00166</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <span class="keyword">remove</span>(<span class="keyword">const</span> QString &amp; sKey)
<a name="l00167"></a>00167 { <span class="keywordflow">return</span> <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;remove(sKey); }
<a name="l00168"></a>00168 
<a name="l00173"></a>00173 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00174"></a><a class="code" href="group___qx_cache.html#ga82a848c3fbc52af86aad56812500b0fb">00174</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <span class="keyword">set</span>(<span class="keyword">const</span> QString &amp; sKey, T &amp; t, <span class="keywordtype">long</span> lCost = 1, <span class="keyword">const</span> QDateTime &amp; dt = QDateTime())
<a name="l00175"></a>00175 {
<a name="l00176"></a>00176    boost::any obj(t);
<a name="l00177"></a>00177    <span class="keywordflow">return</span> <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;insert(sKey, obj, lCost, dt);
<a name="l00178"></a>00178 }
<a name="l00179"></a>00179 
<a name="l00184"></a>00184 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00185"></a><a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa">00185</a> <span class="keyword">inline</span> T <span class="keyword">get</span>(<span class="keyword">const</span> QString &amp; sKey)
<a name="l00186"></a>00186 {
<a name="l00187"></a>00187    boost::any obj = <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;at(sKey);
<a name="l00188"></a>00188    <span class="keywordflow">if</span> (obj.empty()) { <span class="keywordflow">return</span> T(); }
<a name="l00189"></a>00189    <span class="keywordflow">try</span> { <span class="keywordflow">return</span> boost::any_cast&lt;T&gt;(obj); }
<a name="l00190"></a>00190    <span class="keywordflow">catch</span> (<span class="keyword">const</span> boost::bad_any_cast &amp; err) { Q_UNUSED(err); <span class="keywordflow">return</span> T(); }
<a name="l00191"></a>00191    <span class="keywordflow">catch</span> (...) { <span class="keywordflow">return</span> T(); }
<a name="l00192"></a>00192 }
<a name="l00193"></a>00193 
<a name="l00198"></a>00198 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00199"></a><a class="code" href="group___qx_cache.html#ga934010ad97d2ab079e447df20faf8766">00199</a> <span class="keyword">inline</span> <a class="code" href="classqx_1_1_qx_bool.html" title="qx_bool : boolean type with code and description message when an error occured">qx_bool</a> <span class="keyword">get</span>(<span class="keyword">const</span> QString &amp; sKey, T &amp; t, QDateTime &amp; dt)
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201    dt = QDateTime();
<a name="l00202"></a>00202    <span class="keywordflow">if</span> (! <a class="code" href="group___qx_cache.html#ga1b3b7fe7db7920493f40d0adb9c4957e" title="Return true if the cache contains an object associated with key sKey; otherwise return false...">qx::cache::exist</a>(sKey)) { <span class="keywordflow">return</span> <a class="code" href="_qx_bool_8h.html#a40069a4245b458585997dadea3a86b33">qx_bool</a>(<span class="keyword">false</span>, 0, <span class="stringliteral">&quot;[QxOrm] qx::cache : key doesn&#39;t exist in cache&quot;</span>); }
<a name="l00203"></a>00203    boost::any obj = <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;at(sKey);
<a name="l00204"></a>00204    dt = <a class="code" href="classqx_1_1_qx_singleton.html#ac42d9f2442411f1ea7ea0505d224a89c">qx::cache::detail::QxCache::getSingleton</a>()-&gt;insertionDateTime(sKey);
<a name="l00205"></a>00205    <span class="keywordflow">try</span> { t = boost::any_cast&lt;T&gt;(obj); <span class="keywordflow">return</span> <a class="code" href="_qx_bool_8h.html#a40069a4245b458585997dadea3a86b33">qx_bool</a>(<span class="keyword">true</span>); }
<a name="l00206"></a>00206    <span class="keywordflow">catch</span> (<span class="keyword">const</span> boost::bad_any_cast &amp; err) { Q_UNUSED(err); <span class="keywordflow">return</span> <a class="code" href="_qx_bool_8h.html#a40069a4245b458585997dadea3a86b33">qx_bool</a>(<span class="keyword">false</span>, 0, <span class="stringliteral">&quot;[QxOrm] qx::cache : bad any cast exception&quot;</span>); }
<a name="l00207"></a>00207    <span class="keywordflow">catch</span> (...) { <span class="keywordflow">return</span> <a class="code" href="_qx_bool_8h.html#a40069a4245b458585997dadea3a86b33">qx_bool</a>(<span class="keyword">false</span>, 0, <span class="stringliteral">&quot;[QxOrm] qx::cache : unknown cast exception&quot;</span>); }
<a name="l00208"></a>00208 }
<a name="l00209"></a>00209 
<a name="l00214"></a>00214 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00215"></a><a class="code" href="group___qx_cache.html#gaf48befbb27f140da88cb3c3ffe2f4660">00215</a> <span class="keyword">inline</span> <a class="code" href="classqx_1_1_qx_bool.html" title="qx_bool : boolean type with code and description message when an error occured">qx_bool</a> <span class="keyword">get</span>(<span class="keyword">const</span> QString &amp; sKey, T &amp; t)
<a name="l00216"></a>00216 {
<a name="l00217"></a>00217    QDateTime dt;
<a name="l00218"></a>00218    <span class="keywordflow">return</span> qx::cache::get&lt;T&gt;(sKey, t, dt);
<a name="l00219"></a>00219 }
<a name="l00220"></a>00220 
<a name="l00221"></a>00221 } <span class="comment">// namespace cache</span>
<a name="l00222"></a>00222 } <span class="comment">// namespace qx</span>
<a name="l00223"></a>00223 
<a name="l00224"></a>00224 <span class="preprocessor">#endif // _QX_CACHE_H_</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_qx_cache_8h.html">QxCache.h</a>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">Generated on Sun Dec 11 2016 13:41:03 for QxOrm by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
